#define _CRT_SECURE_NO_WARNINGS

#include"conemt.h"

DbLink* createDbLink(void)
{
	DbLink* pLink = (DbLink*)malloc(sizeof(DbLink));
	if (NULL == pLink)
	{
		perror("pLink error");
		return NULL;
	}
	memset(pLink, 0, sizeof(DbLink));
	return pLink;
}
int insertDbLink(DbLink* pHead, int pos, data_type item)
{
	if (NULL == pHead)
	{
		return NULL;
	}
	DbLink* pNew = createDbLink();
	pNew->data = item;
	DbLink* pFind = NULL;
	int i = 0;
	switch (pos)
	{
	default:
		pFind = pHead;
		while (pFind != NULL && i < pos - 1)
		{
			pFind = pFind->pNext;
			i++;
		}
		if (NULL == pFind)
		{
			return POSERROR;
		}
		pNew->pNext = pFind->pNext;
		pNew->pPre = pFind;

		if (pFind->pNext != NULL)
		{
			pFind->pNext->pPre = pNew;
		}
		pFind->pNext = pNew;

		break;
	}
}